﻿using System;
using System.Collections.Specialized;
using System.Configuration;

namespace CS.Config
{
    /// <summary>
    /// 将KeyValue对值集中至Section以方便管理
    /// <example>
    /// <![CDATA[
    /// <configSections>
    ///     <section name="configSection" type="System.Configuration.NameValueSectionHandler" />
    /// </configSections>
    /// <configSection>
    ///     <add key="AppName" value="应用名称" />
    /// </configSection>
    /// ]]>
    /// </example>
    /// </summary>
    [Obsolete("请使用SectionBase",true)]
    public abstract class SectionConfig
    {
        protected SectionConfig(string sectionName)
        {
            KeyValues = ConfigurationManager.GetSection(sectionName) as NameValueCollection;
            if (KeyValues == null)
                throw new ConfigurationErrorsException(string.Format("获取{0}配置出错，请检查配置文件。", sectionName));
        }

        protected NameValueCollection KeyValues { get; private set; }
    }
}